package com.auroramanito.uaa.service;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@RequiredArgsConstructor
@ConditionalOnProperty(prefix = "auroramanito.email-provider",name = "name",havingValue = "smtp")
public class EmailServiceSmtpImpl implements EmailService{
    private final JavaMailSender javaMailSender;

    @Override
    public void send(String email, String msg) {
        val message = new SimpleMailMessage();
        message.setTo(email);
        message.setFrom("2708860396@qq.com");
        message.setSubject("UAA邮箱验证");
        message.setText("验证按为：" + msg);
        javaMailSender.send(message);
    }
}
